#!/usr/bin/env python3
import ipaddress
start_range = "3ffe:0:300::1801:0"
num_ranges = 5
def generate_ipv6_ranges(start_range: str, num_ranges: int):
    start_ip = ipaddress.IPv6Address(start_range)
    original_int_value = int(start_ip)

    ipv6_ranges = []
    for i in range(num_ranges):
        # Increment only the last segment
        incremented_int_value = original_int_value + (i) * 0x10000

        # Convert back to IPv6 address
        current_range_start = ipaddress.IPv6Address(incremented_int_value)
        current_range_end = ipaddress.IPv6Address(incremented_int_value | 0xFFFF)

        # Convert both addresses to simplified form
        start_ip_simplified = current_range_start.compressed
        end_ip_simplified = current_range_end.compressed

        ipv6_ranges.append((start_ip_simplified, end_ip_simplified))

    return ipv6_ranges

def main():
    ipv6_ranges = generate_ipv6_ranges(start_range, num_ranges)
    with open("ipv6_range.txt", "w") as output_file:
        for range_str in ipv6_ranges:
            output_file.write(f"{range_str[0]}-{range_str[1]}\n")

if __name__ == "__main__":
    main()
